import java.util.Scanner;

/**
 * @Title: 小白月赛88B
 * @Author 贾金博
 * @Package PACKAGE_NAME
 * @Date 2024/3/13 18:19
 * @description:
 */
public class 小白月赛88B {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s = new String[10];
        for(int i = 0; i < 5; ++ i ) {
            s[i] = sc.nextLine();
           // System.out.println(s[i]);
        }

        int A = 0, B = 0, C = 0;
        A = s[1].charAt(0) - '0';
        B = s[3].charAt(0) - '0';
        C = s[2].charAt(0) - '0';
        if(s[2].charAt(5) == '&') {
            System.out.println(A & B);
        } else if(s[2].charAt(5) == '>') {
            System.out.println(A | B);
        } else {
            System.out.println(C == 1 ? 0 : 1);
        }
    }
}
